package cn.distant.tank;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Objects;

/**
 * @author distantstar
 * @version 1.0
 * @date 2021
 * @description cn.distant.tank
 * @since JDK1.8
 */
public class ResourceMgr {
    public static BufferedImage bTankL, bTankR, bTankU, bTankD, gTankU, gTankL, gTankR, gTankD;
    public static BufferedImage bulletL, bulletR, bulletU, bulletD;
    public static BufferedImage[] explode = new BufferedImage[16];

    static {
        try {
            bTankU = ImageIO.read(Objects.requireNonNull(
                    ResourceMgr.class.getClassLoader().getResourceAsStream("images/BadTank1.png")));
            bTankR = ImageUtil.rotateImage(bTankU, 90);
            bTankL = ImageUtil.rotateImage(bTankU, -90);
            bTankD = ImageUtil.rotateImage(bTankU, 180);

            gTankU = ImageIO.read(Objects.requireNonNull(
                    ResourceMgr.class.getClassLoader().getResourceAsStream("images/GoodTank1.png")));
            gTankR = ImageUtil.rotateImage(gTankU, 90);
            gTankL = ImageUtil.rotateImage(gTankU, -90);
            gTankD = ImageUtil.rotateImage(gTankU, 180);

            bulletU = ImageIO.read(Objects.requireNonNull(
                    ResourceMgr.class.getClassLoader().getResourceAsStream("images/bulletU.png")));
            bulletR = ImageUtil.rotateImage(bulletU, 90);
            bulletL = ImageUtil.rotateImage(bulletU, -90);
            bulletD = ImageUtil.rotateImage(bulletU, 180);

            for (int i = 0; i < 16; i++) {
                explode[i] = ImageIO.read(Objects.requireNonNull(
                        ResourceMgr.class.getClassLoader().getResourceAsStream("images/e" + (i + 1) + ".gif")));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
